package cn.starsray.service.impl;


import cn.starsray.common.CommonPage;
import cn.starsray.entity.Employee;
import cn.starsray.mapper.EmployeeMapper;
import cn.starsray.service.EmployeeService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import javax.annotation.Resource;
import javax.enterprise.context.ApplicationScoped;

/**
 * (Employee)表服务实现类
 *
 * @author makejava
 * @since 2022-01-17 10:35:52
 */
@ApplicationScoped
public class EmployeeServiceImpl extends ServiceImpl<EmployeeMapper, Employee> implements EmployeeService {

    @Resource
    EmployeeMapper employeeMapper;

    /**
     * 分页查询
     *
     * @param current 当前页码
     * @param size    分页大小
     * @return {@link Page< Employee > }
     */
    public CommonPage<Employee> selectPage(long current, long size) {
        if (current == 0 && size == 0) {
            return null;
        }
        Page<Employee> page = new Page<>(current, size);
        LambdaQueryWrapper<Employee> queryWrapper = new LambdaQueryWrapper<>();
        page = employeeMapper.selectPage(page, queryWrapper);
        return CommonPage.getPage(page);
    }
}